/**
 * Copyright (C) 2013 SHANGHAI VOLKSWAGEN, All rights reserved.
 * License version 1.0, a copy of which has been included with this.
 *
 * @File name：com.market.test.server.test.pumbTest.BubbleSort
 * @Create on：2024/3/12
 * @Author：liuchang
 */
package com.market.test.server.test.pumbTest;

import java.util.Arrays;

/**
 * <p>ClassName：BubbleSort</p >
 * <p>Description：</p >
 * <p>Author：liuchang</p >
 * <p>Date：2024/3/12</p >
 */
public class BubbleSort {
   public  static void bubbleSort(int[] arr){
       int n = arr.length;
       for(int i=0;i<n-i;i++){
           for(int j=0;j<n-1-i;j++){
               if (arr[j]>arr[j+1]){
                   int temp=arr[j];
                   arr[j]=arr[j+1];
                   arr[j+1]=temp;
               }
           }
       }
   }

    public static void main(String[] args) {
        int[] arrToSort={1,9,5,4,6};
        bubbleSort(arrToSort);
        System.out.println(Arrays.toString(arrToSort));
    }
}
